//
// Created by 紫霄 on 2020/4/22.
//

#ifndef LEETCODE_53_H
#define LEETCODE_53_H
#include <vector>
using namespace std;
class Solution {
public:
  int search(vector<int> &nums, int target) {
    int sz = nums.size();
    int ans = 0;
    for (int i = 0; i < sz; ++i) {
      if (nums[i] == target) {
        ++ans;
        if ((i + 1 != sz) && nums[i + 1] != target) {
          return ans;
        }
      }
    }
    return ans;
  }
};
#endif // LEETCODE_53_H
